﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <link href="../zui/css/font-awesome.min.css" rel="stylesheet" />
    <link href="../zui/css/zui.min.css" rel="stylesheet" />
    <link href="../zui/lib/layer/skin/default/layer.css" rel="stylesheet" />
    <link href="../zui/lib/swiper/css/swiper.min.css" rel="stylesheet" />
    <link href="../Plugins/sweetalert/sweetalert.css" rel="stylesheet" />
    <link href="../Plugins/jquery-step/jquery.steps.css" rel="stylesheet" />
    <link href="../zui/lib/datagrid/zui.datagrid.min.css" rel="stylesheet" />
    <link href="../zui/lib/swiper/css/swiper.min.css" rel="stylesheet" />
    <link href="../zui/css/app.css" rel="stylesheet" />
    <title></title>
    <style type="text/css">
        .container {
            font-size: 16px;
            line-height: 30px;
        }

        .bt {
            text-align: right;
            background-color: #F5F5F5;
            color: #000
        }

        .nr {
            text-align: left
        }

        .bt, .nr {
            line-height: 40px;
            /*font-weight:bold;*/
        }

        .row {
            margin-left: 0px !important;
            margin-right: 0px !important;
        }

        html, body {
            position: relative;
            height: 100%;
        }

        body {
            background: #fff;
            font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .swiper-container {
            width: 100%;
            height: 90%;
        }

        .swiper-slide {
            font-size: 18px;
            height: auto;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            padding: 0px;
            padding-left: -10px
        }
    </style>
</head>
<body>
    <div class="container" style="padding-left:0px !important;max-width:870px">
        <div id="recordContent" style="width:870px;height:430px; overflow-y:scroll; overflow-x:hidden !important">
            <h3 id="ggg">试验基本信息</h3>
            <hr>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    时间：
                </div>
                <div class="col-xs-3 nr" id="startTime">

                </div>
                <div class="col-xs-3 bt">
                    试验次数：
                </div>
                <div class="col-xs-3 nr" id="SyCount">

                </div>
            </div>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    材料：
                </div>
                <div class="col-xs-3 nr" id="Sycl">
                </div>
                <div class="col-xs-3 bt">
                    设定温度：
                </div>
                <div class="col-xs-3 nr" id="Sywd">

                </div>
            </div>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    类型：
                </div>
                <div class="col-xs-3 nr" id="Sylx">

                </div>
                <div class="col-xs-3 bt">
                    试验人：
                </div>
                <div class="col-xs-3 nr" id="Syr">

                </div>
            </div>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    结论：
                </div>
                <div class="col-xs-9 nr" id="Syjl">

                </div>
            </div>
            <!--<h3>试验1详情</h3>
            <hr>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    开始时间：
                </div>
                <div class="col-xs-3 nr" id="bzstartTime">
                    2018/2/7 16:46:32
                </div>
                <div class="col-xs-3 bt">
                    结束时间：
                </div>
                <div class="col-xs-3 nr" id="bzstopTime">
                    2018/2/7 16:46:32
                </div>
            </div>
            <div class="row" style="color:#f1a325;text-align:center">
                <div class="col-xs-3 bt">
                    样品试验现象：
                </div>
                <div class="col-xs-3 nr" id="ypxx">

                </div>
                <div class="col-xs-3 bt">
                    样品温度变化：
                </div>
                <div class="col-xs-3 nr" id="wdbh">
                    未发生试样自加热温度连续10秒大于等于3℃
                </div>
            </div>
            <div id="container1" style="height: 350px; min-width: 310px;margin-top:15px"></div>

            <div style="display:none">
                <h3>试验2详情</h3>
                <hr>
                <div class="row" style="color:#f1a325;text-align:center">
                    <div class="col-xs-3 bt">
                        开始时间：
                    </div>
                    <div class="col-xs-3 nr" id="bzstartTime">
                        2018/2/7 16:46:32
                    </div>
                    <div class="col-xs-3 bt">
                        结束时间：
                    </div>
                    <div class="col-xs-3 nr" id="bzstopTime">
                        2018/2/7 16:46:32
                    </div>
                </div>
                <div class="row" style="color:#f1a325;text-align:center">
                    <div class="col-xs-3 bt">
                        样品试验现象：
                    </div>
                    <div class="col-xs-3 nr" id="ypxx">

                    </div>
                    <div class="col-xs-3 bt">
                        样品温度变化：
                    </div>
                    <div class="col-xs-3 nr" id="wdbh">
                        未发生试样自加热温度连续10秒大于等于3℃
                    </div>
                </div>
                <div id="container2" style="height: 350px; min-width: 310px;margin-top:15px"></div>
            </div>-->
        </div>
        <div class="shiyan-footer" style="position:fixed; bottom:0px">
            <button style="float:left;margin-right:5px" class="btn btn-default btn-lg home-btn" type="button">返回列表</button>
            <!--<button style="float:right;margin-right:5px" class="btn btn-default btn-lg sxt-btn" type="button">修改数据</button>-->
            <button style="float:right" class="btn btn-danger btn-lg sxt-btn" id="deleteReport" type="button">删除报表</button>
            <button style="float:right;margin-right:5px" class="btn btn-primary btn-lg start-shiyan" id="report-btn" type="button">导出报表</button>
            <button style="float:right;margin-right:5px" class="btn btn-default btn-lg openVideoPath" type="button">查看视频</button>
        </div>
    </div>



    <script src="../zui/lib/jquery/jquery.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/highstock.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/modules/exporting.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/modules/export-data.js"></script>
    <script src="../zui/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="../zui/lib/layer/layer.js"></script>
    <script src="../zui/lib/swiper/js/swiper.min.js"></script>
    <script src="../Plugins/sweetalert/sweetalert.min.js"></script>
    <script src="../Plugins/ECharts/echarts.simple.min.js"></script>
    <script src="../Plugins/jquery-step/jquery.steps.min.js"></script>

    <script src="../zui/js/zui.min.js"></script>
    <script src="../zui/lib/datagrid/zui.datagrid.min.js"></script>
    <script src="../static/jquery.flot.js"></script>
    <script src="../zui/lib/swiper/js/swiper.min.js"></script>
    <script src="../Plugins/linqjs/linq.min.js"></script>
    <script src="../zui/js/utils.js"></script>
    <script src="../zui/js/app.js"></script>
    <script type="text/javascript">

        var experimentId = getQueryString("experimentId");
        var imageStrArray = ["","","",""];
        $(function () {
            Highcharts.setOptions({
                global: {
                    timezoneOffset: -8 * 60
                }
            });
            $("#ggg").text(experimentId);
            //$(".openVideoPath1").on("click", function (event) {
            //    event.preventDefault();
            //    html2canvas(document.getElementById("container1_1"), {
            //        allowTaint: true,
            //        taintTest: false,
            //        onrendered: function (canvas) {
            //            canvas.id = "mycanvas";

            //            //生成base64图片数据
            //            var dataUrl = canvas.toDataURL();
            //            var newImg = document.createElement("img");
            //            newImg.src = dataUrl;
            //            //document.body.appendChild(newImg);
            //            $("#ceshi1").prop("src", dataUrl);
            //        }
            //    });
            //});

            AjaxGet("正在获取试验数据...", "getExperimentInfo",
                {
                    experiment_id: experimentId
                }, function (res) {

                    $("#report-btn").click(function () {
                        $(imageStrArray).each(function (index, obj) {
                            if (imageStrArray[index] != "") {
                                imageStrArray[index]= $("#" + imageStrArray[index]).highcharts().getSVG();
                            }
                        });
                        var filePath = top.sysControl.SaveFileDialog("选择保存路径", "fwefwefgegreg.xls");
                        if (filePath != "" && filePath != null) {
                            var loadingIndex = top.layer.msg("正在导出报表，请耐心等待", {
                                time: 0, icon: 16, shade: 0.01
                            });
                            top.myService.ExportRecord(res, filePath, JSON.stringify(imageStrArray), function (res) {
                                if (JSON.parse(res).status == 0) {
                                    top.layer.close(loadingIndex);
                                    top.layer.msg("导出成功！");
                                }
                            })
                        }

                    });
                    var obj = JSON.parse(res).data;
                    //top.layer.alert(JSON.stringify(obj[2]))
                    var eInfo = obj[0];
                    $("#startTime").text(eInfo.start_time);
                    $("#Sycl").text(eInfo.material_name);
                    $("#Sylx").text(getSylx(eInfo.experiment_type));
                    //$("#Syjl").text(eInfo.result);
                    $("#Sywd").text("75°C");
                    $("#Syr").text(eInfo.experiment_user_name);
                    $("#SyCount").text(eInfo.total_count);
                    var result = true;
                    $(obj[1]).each(function (index, el) {
                        if (index == 0) {
                            $("#startTime").text(this.start_time);
                        }
                        var c = $(`<h3>试验${(index + 1)}详情</h3><hr>` +
                            `<div class="row" style="color:#f1a325;text-align:center">` +
                            `<div class="col-xs-3 bt">开始时间：</div><div class="col-xs-3 nr" id="bzstartTime">${this.start_time}</div>` +
                            `<div class="col-xs-3 bt">结束时间：</div><div class="col-xs-3 nr" id="bzstartTime">${this.end_time}</div></div>` +
                            `<div class="row" style="color:#f1a325;text-align:center">` +
                            `<div class="col-xs-3 bt">样品试验现象：</div><div class="col-xs-3 nr" id="bzstartTime">${getSampleStatusStr(this.sample_result_code)}</div>` +
                            `<div class="col-xs-3 bt">` + (eInfo.experiment_type == 1 ? "" : `样品温度变化：`) + `</div><div class="col-xs-3 nr" id="bzstartTime">${eInfo.experiment_type == 1 ? "" : (this.temp_result_code == 0 ? "未发生试样自加热温度连续10秒大于等于3℃情况" : "发生试样自加热温度连续10秒大于等于3℃情况")}</div></div>` +
                            `<div id="container${(index + 1)}_1" style="height: 350px; min-width: 310px;margin-top:15px"></div><div id="container${(index + 1)}_2" style="height: 350px; min-width: 310px;margin-top:15px"></div>` +
                            (eInfo.experiment_type == 2 ? `<div id="container${(index + 1)}_3" style="height: 350px; min-width: 310px;margin-top:15px"></div>` : ''));

                        if (this.temp_result_code != 0) {
                            result = false;
                        }
                        if (this.sample_result_code == 1 || this.sample_result_code == 2 || this.sample_result_code == 3) {
                            result = false;
                        }

                        //if (eInfo.experiment_type == 2) {
                        //    c.append(`<div id="container${(index + 1)}_2" style="height: 350px; min-width: 310px;margin-top:15px"></div>`);
                        //}
                        $("#recordContent").append(c);
                        if (eInfo.experiment_type == 1) {
                            CreateStockChart(`container${(index + 1)}_1`, "烘箱温度变化图", JSON.parse(obj[2][3 * index + 1]));
                            CreateStockChart(`container${(index + 1)}_2`, "烘箱温度变化图（辅助）", JSON.parse(obj[2][3 * index + 2]));
                            imageStrArray[2 * index] = `container${(index + 1)}_1`;

                        }
                        else {
                            CreateStockChart(`container${(index + 1)}_1`, "样品温度变化图", JSON.parse(obj[2][3 * index]));
                            CreateStockChart(`container${(index + 1)}_2`, "烘箱温度变化图", JSON.parse(obj[2][3 * index + 1]));
                            CreateStockChart(`container${(index + 1)}_3`, "烘箱温度变化图（辅助）", JSON.parse(obj[2][3 * index + 2]));
                            imageStrArray[2 * index] = `container${(index + 1)}_2`;
                            imageStrArray[2 * index + 1] = `container${(index + 1)}_1`;

                        }

                    });
                    $("#Syjl").text(result ? "通过" : "未通过");
                    
                    //imageStrArray.splice(0, 1, $("#container1_1").highcharts().getSVG());
                    //alert($("#container1_1").highcharts().getSVG());
                    //var firstSy = (obj[1])[0];
                    //$("#ypxx").text(getSampleStatusStr(firstSy.sample_result_code));
                    //$("#bzstartTime").text(firstSy.start_time);
                    //$("#bzstopTime").text(firstSy.end_time);

                    //var tempIndex = 0;
                    //var tempTitle = "";
                    //if (eInfo.experiment_type == 1) {
                    //    tempIndex = 1;
                    //    tempTitle = "水域温度变化图";
                    //} else {
                    //    tempIndex = 0;
                    //    tempTitle = "样品温度变化图";
                    //}
                    //var tempjson1 = JSON.parse(obj[2][tempIndex]);
                    //// Create the chart
                    //Highcharts.stockChart('container1', {
                    //    rangeSelector: {
                    //        enabled: false
                    //    },
                    //    scrollbar: {
                    //        barBackgroundColor: 'gray',
                    //        barBorderRadius: 7,
                    //        barBorderWidth: 0,
                    //        buttonBackgroundColor: 'gray',
                    //        buttonBorderWidth: 0,
                    //        buttonArrowColor: 'yellow',
                    //        buttonBorderRadius: 7,
                    //        rifleColor: 'yellow',
                    //        trackBackgroundColor: 'white',
                    //        trackBorderWidth: 1,
                    //        trackBorderColor: 'silver',
                    //        trackBorderRadius: 7
                    //    },
                    //    exporting: {
                    //        enabled: false
                    //    },
                    //    credits: {
                    //        enabled: false
                    //    },
                    //    title: {
                    //        text: tempTitle,
                    //        margin: 10,
                    //        style: { "fontSize": "22px" },
                    //    },
                    //    tooltip: {
                    //        formatter: function () {
                    //            return Highcharts.dateFormat('时间：%Y-%m-%d %H:%M:%S', this.x) + '<br/>温度：' +
                    //                Highcharts.numberFormat(this.y, 2) + '℃';
                    //        }
                    //    },
                    //    series: [{
                    //        name: '试样温度',
                    //        data: tempjson1,
                    //        tooltip: {
                    //            valueDecimals: 2
                    //        }
                    //    }]
                    //});

                }, function (res) {
                    top.layer.alert("此报表数据已被损坏！");

                });
            $(".openVideoPath").click(function () {
                top.myService.OpenExplore(experimentId, 0);

            });
            $("#deleteReport").click(function () {

                AjaxGet("正在获取试验数据...", "deleteExperiment",
                    {
                        experiment_id: experimentId
                    }, function (res) {

                        $("#content-frame", parent.document).attr("src", "DataReport.html");
                    });
            });
            $(".home-btn").click(function () {
                $("#userinfo-btn", top.document).removeClass("disabled");
                $("#content-frame", top.document).attr("src", "DataReport.html");
            });
            //$.getJSON('https://www.highcharts.com/samples/data/aapl-c.json', function (data) {
            //    // Create the chart
            //    Highcharts.stockChart('container2', {
            //        rangeSelector: {
            //            enabled: false
            //        },
            //        scrollbar: {
            //            barBackgroundColor: 'gray',
            //            barBorderRadius: 7,
            //            barBorderWidth: 0,
            //            buttonBackgroundColor: 'gray',
            //            buttonBorderWidth: 0,
            //            buttonArrowColor: 'yellow',
            //            buttonBorderRadius: 7,
            //            rifleColor: 'yellow',
            //            trackBackgroundColor: 'white',
            //            trackBorderWidth: 1,
            //            trackBorderColor: 'silver',
            //            trackBorderRadius: 7
            //        },
            //        exporting: {
            //            enabled: false
            //        },
            //        credits: {
            //            enabled: false
            //        },
            //        title: {
            //            text: '样品温度变化图',
            //            margin: 10,
            //            style: { "fontSize": "22px" },
            //        },

            //        series: [{
            //            name: '试样温度',
            //            data: data,
            //            tooltip: {
            //                valueDecimals: 2
            //            }
            //        }]
            //    });
            //});

        });
        function getSylx(lx) {
            var s = "";
            switch (lx) {
                case 1:
                    s = "阶段一试验";
                    break;
                case 2:
                    s = "阶段2试验";
                    break;

                default:
            }
            return s;
        }
        function CreateStockChart(id, tempTitle, tempjson) {
            Highcharts.stockChart(id, {
                rangeSelector: {
                    enabled: false
                },
                scrollbar: {
                    barBackgroundColor: 'gray',
                    barBorderRadius: 7,
                    barBorderWidth: 0,
                    buttonBackgroundColor: 'gray',
                    buttonBorderWidth: 0,
                    buttonArrowColor: 'yellow',
                    buttonBorderRadius: 7,
                    rifleColor: 'yellow',
                    trackBackgroundColor: 'white',
                    trackBorderWidth: 1,
                    trackBorderColor: 'silver',
                    trackBorderRadius: 7
                },
                exporting: {
                    enabled: false
                },
                credits: {
                    enabled: false
                },
                title: {
                    text: tempTitle,
                    margin: 10,
                    style: { "fontSize": "22px" },
                },
                tooltip: {
                    formatter: function () {
                        return Highcharts.dateFormat('时间：%Y-%m-%d %H:%M:%S', this.x) + '<br/>温度：' +
                            Highcharts.numberFormat(this.y, 2) + '℃';
                    }
                },
                xAxis: {
                    gapGridLineWidth: 0,
                    dateTimeLabelFormats: {
                        millisecond: '%H:%M:%S.%L',
                        second: '%H:%M:%S',
                        minute: '%H:%M',
                        hour: '%H:%M',
                        day: '%m-%d',
                    },
                    crosshair: {
                        label: {
                            format: '%Y-%m-%d'
                        }
                    }
                },
                series: [{
                    name: '温度',
                    data: tempjson,
                    tooltip: {
                        valueDecimals: 2
                    }
                }]
            });
        }
    </script>

</body>
</html>